/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Date;
import model.Personne;

/**
 *
 * @author Paul
 */
public class DAOPersonne {

private String daoLogin;
private String daoPassword;
    public Personne rechercheUtilisateur(String login, String mdp) throws SQLException {
       
            /*
             * Base de données
             */
            PreparedStatement st = null;
            Personne p=null;
            try {
                Connection conn = DBConnection.getConnection();
                String query = "select * from personne where login='"+login+"' and password='"+mdp+"';";
                st = conn.prepareStatement(query);
                ResultSet res = st.executeQuery(query);
                if(res.next()){
                    String log = res.getString("login");
                    String password = res.getString("mdp");
                   String nom= res.getString("nom");
                   String prenom=res.getString("prenom");
                   int idp=0;
                   String type=null;
                   Date d =null;
                    p = new Personne(idp,nom,prenom,d,type,log,password);
                }
                }catch(SQLException e){
                    e.printStackTrace();
            }
           
            return p;
             } 

    

    public boolean checkLogin(String login) {
        return (!daoLogin.equals(login));
    }
    
    public boolean checkPassword(String password) {
        return (!daoPassword.equals(password));
    }
    
    public boolean isNotEmptyLogin(String login) {
        return (!"".equals(login));
    }

    public boolean isNotEmptyPassword(String password) {
        return (!"".equals(password));
    }
    
}
